public class ASTCDIRRDeclaration extends SimpleNode {
	
	protected String identifier="";
	protected boolean isDefinition=false;
	protected boolean isRole=false;
	protected boolean isInterface=false;
	protected boolean isAbstract=false;	
	protected boolean hasExtends = false;
	protected String  extend = "";
	protected boolean hasImplements = false;
	protected boolean isRelation=false;
	protected String relationVarTo=null;
	protected String relationVarFrom=null;
	protected int numOfDefine=0;

	
	
  public ASTCDIRRDeclaration(int id) {
    super(id);
  }

  public ASTCDIRRDeclaration(JavaRolePreCompiler p, int id) {
    super(p, id);
  }


  /** Accept the visitor. **/
  public Object jjtAccept(JavaRolePreCompilerVisitor visitor, Object data) {
    return visitor.visit(this, data);
  }
  
  public void setIdentifier(String text) {
    identifier = text;
  }

  public String getIdentifier() {
    return identifier;
  }

public void setIsDefinition(){
	isDefinition=true;
}

public boolean isDefinition(){
	return isDefinition;
}

public void setIsAbstract(){
	isAbstract=true;
}

public boolean isAbstract(){
	return isAbstract;
}

public void setIsRole(){
	isRole=true;
}

public boolean isRole(){
	return isRole;
}

public void setIsRelation(){
	isRelation=true;
}

public boolean isRelation(){
	return isRelation;
}

public void setIsInterface(){
	isInterface=true;
}

public boolean isInterface(){
	return isInterface;
}

  public void setHasExtends() {
     hasExtends = true;
  }
  public boolean hasExtends() {
     return hasExtends;
  }

  public void setExtend(String extend){
	  this.extend=extend;
  }
  
  public String getExtend(){
	  return extend;
  }
  public void setHasImplements() {
     hasImplements = true;
  }
  public boolean hasImplements() {
     return hasImplements;
  }


  public void addNumOfDefine(){
	  numOfDefine++;
  }
	
  public int getNumOfDefine(){
      return numOfDefine;
  }

  public String getTo(){
	  return relationVarTo;
  }
  
  public String getFrom(){
	  return relationVarFrom;
  }
  
  public void setTo(String to){
	  relationVarTo=to;
  }
  
  public void setFrom(String from){
	  relationVarFrom=from;
  }
  
  public boolean hasFrom(){
	  return relationVarFrom!=null;
  }
  
  public boolean hasTo(){
	  return relationVarTo!=null;
  }


  public ASTCDIRRDeclaration getRelationAncestor(){
	  SimpleNode ancestor=(SimpleNode) this.jjtGetParent();
	  while(!(ancestor instanceof ASTCDIRRDeclaration)){
		  if (ancestor instanceof ASTTypeDeclaration || ancestor==null) return null;
		  ancestor = (SimpleNode) ancestor.jjtGetParent();		  
	  }
	  if (((ASTCDIRRDeclaration)ancestor).isRelation()){
		  if (((ASTCDIRRDeclaration)ancestor).relationVarFrom==null) 
			((ASTCDIRRDeclaration)ancestor).relationVarFrom=this.getIdentifier();
		  else ((ASTCDIRRDeclaration)ancestor).relationVarTo=this.getIdentifier();//if are more then 2 is checked later
		  
		  return (ASTCDIRRDeclaration) ancestor;
	  }
	  else return null;

	  
  }

}
	


